package com.sun.designpatternsdemo.facade.bean

import android.util.Log

/**
 * 版权：xx公司 版权所有
 * @author sun
 * 版本：1.0
 * 创建日期：2021/7/1 9:27
 * 描述：实体
 *
 */
//灯光
class Light {
    fun down() {
        Log.e("Light", "---将灯光调暗")
    }

    fun up() {
        Log.e("Light", "---将灯光调亮")
    }
}

//电脑
class Computer() {
    fun on() {
        Log.e("Computer", "---打开电脑")
    }

    fun off() {
        Log.e("Computer", "---关闭电脑")
    }
}

// 播放器
class Player {
    fun on() {
        Log.e("Player", "---打开播放器")
    }

    fun off() {
        Log.e("Player", "---关闭播放器")
    }

    fun make3DListener() {
        Log.e("Player", "---将播放器音调设为环绕立体声 ")
    }
}

//爆米花机
class PopcornPopper {
    fun on() {
        Log.e("PopcornPopper", "---打开爆米花机")
    }

    fun off() {
        Log.e("PopcornPopper", "---关闭爆米花机")
    }

    fun makePopcorn() {
        Log.e("PopcornPopper", "---制作爆米花")
    }
}

class Projector {
    fun on() {
        Log.e("Projector", "---打开投影仪")
    }

    fun off() {
        Log.e("Projector", "---关闭投影仪")
    }

    fun close() {
        Log.e("Projector", "---收起投影仪投影区")
    }

    fun open() {
        Log.e("Projector", "---放下投影仪投影区")
    }
}

class HomeTheaterFacade(
    val computer: Computer,
    val light: Light,
    val player: Player,
    val popcornPopper: PopcornPopper,
    val projector: Projector
) {
    //一键观影
    fun watchMovie() {
        computer.on()
        light.down()
        popcornPopper.on()
        popcornPopper.makePopcorn()
        projector.on()
        projector.open()
        player.on()
        player.make3DListener()
    }

    //一键关闭
    fun stopMovie() {
        computer.off()
        light.up()
        player.off()
        popcornPopper.off()
        projector.close()
        projector.off()
    }
}